home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / ste / sam_seq.lzh / SAM_SEQ / BASICS / GFA / GFADEMO.LST next >
File List  |  1993-01-04  |  12KB  |  217 lines

  1. Rem ***************************************************************************
  2. Rem *                Simple Sequence Demo for GFA Basic                       *
  3. Rem *                   by I.Hancock- PHAZE Shift Inc.                        *
  4. Rem ***************************************************************************
  5. Rem * Reserve memory for code & sequence (& if wanted alternate mixes)        *
  6. Rem * & allocate addresses for each. Seq% should be dimensioned to the desktop*
  7. Rem * size in bytes of your sequence file. You can have as many alternative   *
  8. Rem * mixes as you like and should dimension each array to DT size in bytes.  *
  9. Rem * Mc% is the Machine Code to play the sequence and MUST be included.      *
  10. Rem * These arrays are where you will load the files into memory.             *
  11. Rem ***************************************************************************
  12. Dim Mc%(1000),Seq%(400000),Amix%(2000)
  13. Code%=Varptr(Mc%(0))
  14. Sequence%=Varptr(Seq%(0))
  15. Mix%=Varptr(Amix%(0))
  16. Finish%=1
  17. C_down%=1
  18. Rem ***************************************************************************
  19. Rem * Code% and Sequence% and Mix% are the relevent start addresses.          *
  20. Rem * Finish% is a variable passed to the machine code routine. It is         *
  21. Rem * incremented every time a sample is played from the sequence or mix and  *
  22. Rem * set to zero when the sequence or mix finish (after all loops).          *
  23. Rem * C_down% is another passed variable. It counts down each loop.           *
  24. Rem ***************************************************************************
  25. Rem *                            Load machine code                            *
  26. Rem ***************************************************************************
  27. Print "Loading Code..."
  28. Bload "a:sam_seq\basics\gfa\SEQUENCE.BIN",Code%
  29. Rem ***************************************************************************
  30. Rem *                           Define CALL addresses                         *
  31. Rem ***************************************************************************
  32. Play%=Code%+140
  33. Halt%=Code%+250
  34. Rem ***************************************************************************
  35. Rem * Play% and Halt% are the start addresses of the machine code routines.   *
  36. Rem * Do NOT use call Halt% until after you have called Play% at least once   *
  37. Rem ***************************************************************************
  38. Rem *                           Define storage offsets                        *
  39. Rem ***************************************************************************
  40. Seqstart%=Code%+28
  41. Fin%=Code%+32
  42. Ever%=Code%+36
  43. Anothermix%=Code%+40
  44. Rem ***************************************************************************
  45. Rem * Seqstart% is the address to which you must write the start address of   *
  46. Rem * the sequence. You MUST always have a sequence even if you only use the  *
  47. Rem * mixes. Since the *.SEQ file contains the samples to be used by the mix. *
  48. Rem * *.MIX files only contain the order of play information, this is why they*
  49. Rem * are alot smaller. Using a MIX file which is not correct for the current *
  50. Rem * sequence may CRASH the computer. To be sure a MIX file will work with a *
  51. Rem * sequence:- load the sequence into my sequencing program, then load      *
  52. Rem * the MIX file. If the MIX file loads then it IS OK.                      *
  53. Rem * Fin% is the address to which you must write the address of your Finish% *
  54. Rem * flag.: Ever% is the address to which your must write the address of your*
  55. Rem * C_down variable.(count down) mode.                                      *
  56. Rem * Anothermix% is the address to which must write the start address of     *
  57. Rem * a separate mix.                                                         *
  58. Rem ***************************************************************************
  59. Rem *                         Load sequence into memory                       *
  60. Rem ***************************************************************************
  61. Print "Loading Sequence."
  62. Bload "a:\sam_seq\sequence.s\tryme.SEQ",Sequence%
  63. Print "Loading Mix."
  64. Bload "a:\sam_seq\sequence.s\mono_2.MIX",Mix%
  65. Rem ***************************************************************************
  66. Rem *                        Poke Sequence data into code                     *
  67. Rem ***************************************************************************
  68. Lpoke Seqstart%,Sequence%
  69. Lpoke Fin%,Varptr(Finish%)
  70. Lpoke Ever%,Varptr(C_down%)
  71. Lpoke Anothermix%,0
  72. On Break Gosub Sam_stop
  73. On Error Gosub Sam_stop
  74. Rem ***************************************************************************
  75. Rem * The On Error and On Break commands try to ensure you do not stop a prog.*
  76. Rem * While a sequence is playing. The sub-routine sam_stop checks Finish%    *
  77. Rem * If it is 0 then it assumes no seq. is playing, else it calls Halt%      *
  78. Rem * NOTE: if you stop a program while a sequence is playing itis VERY likely*
  79. Rem * to crash GFA basic rather severely - YOU HAVE BEEN WARNED               *
  80. Rem ***************************************************************************
  81. Rem * The 1st Lpoke puts the start address of the sequence into the Machine - *
  82. Rem * -code. The second puts the address of your Finish% flag variable into MC*
  83. Rem * The MC will count Finish% up each time it plays another sample from the *
  84. Rem * sequence/mix. It is finally set to zero when the seq/mix has finished.  *
  85. Rem * It is set to 1 at the start of each loop and NEVER goes to zero when in *
  86. Rem * infinite loop mode.(for obvious reasons - it never finishes!            *
  87. Rem * The third Lpoke puts the address of your C_down% (count down) variable  *
  88. Rem * into the MC. The MC will count C_down% down to zero - when the looping  *
  89. Rem * will stop. You can change the value of either of the prev. 2 variables  *
  90. Rem * HOWEVER if Finish% counts above $FFFFFFFF it will reset to zero which   *
  91. Rem * your program may see as sequence finished ! NOTE: setting Finish% to 0  *
  92. Rem * will NOT stop the sequence. The MC ONLY counts Finish% for your benefit *
  93. Rem * If you set C_down% to zero during or before a sequence is playing then  *
  94. Rem * infinite mode is engaged. In the same way setting it to 1 will make it  *
  95. Rem * stop at the end of the current loop. Since the MC treats both variables *
  96. Rem * un-signed using negative no.s will be equivalent to using V. High posit.*
  97. Rem * no.s.                                                                   *
  98. Rem * I DO NOT ADVISE USING NEGATIVE NUMBERS !!                               *
  99. Rem * The final Lpoke tells the MC to use (all of) the sequence and not a sep.*
  100. Rem * mix. Changing either the 1st or last Lpoke while a sequence is playing  *
  101. Rem * will have NO effect since they are only used to initialise. You MUST    *
  102. Rem * STOP the current sequence, re-poke the values, then call Play% again.   *
  103. Rem ***************************************************************************
  104. Rem *                     Now REPLAY the sequence Once                        *
  105. Rem ***************************************************************************
  106. Lpoke Anothermix%,0
  107. Finish%=1
  108. C_down%=1
  109. Call Play%
  110. Rem
  111. Rem ** 4 commands start the sequence (ALL MODE, not using mix) **
  112. Rem ** Below ⇩ waits for it to stop.    **
  113. Rem ** and checks for key press         **
  114. Rem
  115. Print "Play once first.."
  116. Pause 50
  117. While Finish%<>0
  118.   Print "Still working with Music in background ";
  119.   K$=Inkey$
  120.   If K$=" " Then
  121.     Call Halt%
  122.     Print
  123.     Print
  124.     Print "Last sample playing was (finish% - 1) = ";Finish%-1
  125.     Finish%=0
  126.   Endif
  127. Wend
  128. Pause 100
  129. Rem ***************************************************************************
  130. Rem *                    Now REPLAY the sequence 5 Times                      *
  131. Rem * It IS IMPORTANT that the previous sequence was Halted before the next   *
  132. Rem ***************************************************************************
  133. Lpoke Anothermix%,Mix%
  134. Finish%=1
  135. C_down%=5
  136. Call Play%
  137. Rem
  138. Rem ** Anothermix% is sent the address of the mix **
  139. Rem ** And C_down% is set to loop 5 times         **
  140. Rem
  141. Print
  142. Print